package com.bw.zg2.http

import com.blankj.utilcode.util.SPUtils
import com.bw.zg2.utils.SpUtil
import okhttp3.Interceptor
import okhttp3.Response

/**
 *
 * @ClassName: TokenInterceptor
 * @Description: 自定义token拦截器
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/12 3:47 PM
 * @Version: 1.0
 */
class TokenInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        //拦截request，给他添加header 参数
        val request = chain.request()
            .newBuilder()
            .addHeader("token", SpUtil.getString("token"))
            .build()
        return chain.proceed(request)
    }

}
